package com.dstz.agilebpm.springcloud.sys.rest;

import com.dstz.base.api.aop.annotion.CatchErr;
import com.dstz.base.api.response.impl.ResultMsg;
import com.dstz.base.rest.GenericController;
import com.dstz.org.api.model.IUser;
import com.dstz.org.api.model.IUserRole;
import com.dstz.org.api.service.UserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 用户扩展接口控制器
 *
 * @author wacxhs
 */
@RestController
@RequestMapping("/org/userExtra")
public class UserExtraController extends GenericController {

    private final Logger logger = LoggerFactory.getLogger(UserExtraController.class);

    @Autowired
    private UserService userService;


    /**
     * 根据组织id和组织类型获取用户列表。
     *
     * @param groupId   组织列表
     * @param groupType 组织类型
     * @return 接口响应结果
     */
    @CatchErr
    @GetMapping("getUserListByGroup")
    public ResultMsg<List<IUser>> getUserListByGroup(
            @RequestParam("groupType") String groupType,
            @RequestParam("groupId") String groupId
    ) {
        return getSuccessResult(userService.getUserListByGroup(groupType, groupId));
    }

    /**
     * 获取用户的角色关系
     *
     * @param userId 用户编号
     * @return 接口响应结果
     */
    @CatchErr
    @GetMapping("getUserRole")
    public ResultMsg<List<IUserRole>> getUserRole(@RequestParam("userId") String userId) {
        return getSuccessResult(userService.getUserRole(userId));
    }

}
